/* main.c */
#include "app_inc.h"

MPU9250_SensorData_T gAppMpu9250SensorDataStruct;

int main(void)
{
    volatile uint8_t ch;

    BSP_InitSystem();
    BSP_InitStdioLPUART(115200U);

    printf("\r\n\r\nLPSPI_MPU9250 Example.\r\n");
    printf("Compiled on %s, %s\r\n\r\n", __DATE__, __TIME__);

    /* 初始化LPSPI_EDMA传输 */
    MPU9250_Init();
    printf("MPU9250_Init() Done.\r\n");

    /* 读取MPU9250的ID寄存器值，验证传感器已经上线 */
    while ( !MPU9250_Probe() )
    {
        printf("MPU9250_Probe() Failed.\r\n");
    }
    printf("MPU9250_Probe() Done.\r\n");

    /* 配置MPU9250的工作方式，转换完成后产生中断 */
    MPU9250_Setup();

    while (1)
    {
        getchar();

        MPU9250_UpdateSensorData(NULL);
        MPU9250_GetSensorData(&gAppMpu9250SensorDataStruct);
        printf("%8d, %8d, %8d, %8d, %8d, %8d, %8d\r\n",
            gAppMpu9250SensorDataStruct.AccX,
            gAppMpu9250SensorDataStruct.AccY,
            gAppMpu9250SensorDataStruct.AccZ,
            gAppMpu9250SensorDataStruct.GyrX,
            gAppMpu9250SensorDataStruct.GyrY,
            gAppMpu9250SensorDataStruct.GyrZ,
            gAppMpu9250SensorDataStruct.Temperature
        );
        //printf("\r\n");
    }
}


/* EOF. */

